<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Contract</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="lib/fxsupport.js"></script>
<script type="text/javascript" src="lib/jquery-1.8.3.js"></script>
<script type="text/javascript" src="lib/JSResource.js"></script>
<script type="text/javascript" src="lib/urlpara.js"></script>
<!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* 此 1px 负边距可以放置在此布局中的任何列中，且具有相同的校正效果。 */
ul.nav a { zoom: 1; }  /* 缩放属性将为 IE 提供其需要的 hasLayout 触发器，用于校正链接之间的额外空白 */
</style>
<![endif]-->
</head>

<body>
	<div class="container">
		<div class="header">
			<a href="#"><img src="logo.jpg" alt="在此处插入徽标" name="Insert_logo"
				width="20%" height="90" id="Insert_logo"
				style="background-color: #8090AB; display:block;" /> </a>
			<!-- end .header -->
		</div>
		<div class="sidebar1">
			<ul class="nav">
				<li><a href="home.jsp">Department Home</a></li>
				<li><a href="contributorlist.htm">Contributor List</a></li>
				<li><a href="memberlist.htm">Member List</a></li>
			</ul>
			<!-- end .sidebar1 -->
		</div>
		<div class="content">
			<h1 id="title">Contract</h1>
			<p id="description">Description</p>
			<p id="amount">Amount</p>
			<p id="time">Time</p>
			<div id="extend"></div>
			<h4>Contributors</h4>
			<table id="contributors" width="95%" border="1" align="center"
				cellpadding="0" cellspacing="0">
				<tr>
					<th scope="col">id</th>
					<th scope="col">name</th>
					<th scope="col">size</th>
					<th scope="col">type</th>
					<th scope="col">operation</th>
				</tr>
				<tr>
					<td colspan="5" align="right" scope="col"><a id="addc"
						href="#">add</a>
					</td>
				</tr>
			</table>
			<h4>Payings</h4>
			<table id="payings" width="95%" border="1" align="center"
				cellpadding="0" cellspacing="0">
				<tr>
					<th scope="col">date</th>
					<th scope="col">currency</th>
					<th scope="col">rate</th>
					<th scope="col">amount</th>
					<th scope="col">operation</th>
				</tr>
				<tr>
					<td colspan="5" align="right" scope="col"><a id="addp"
						href="#">add</a>
					</td>
				</tr>
			</table>
			<!-- end .content -->
		</div>
		<div class="footer">
			<!-- end .footer -->
		</div>
		<!-- end .container -->
	</div>
	<script type="text/javascript">
		var id = getParamFromURL("id");
		resource
				.GET(
						"contract/contract/" + id,
						function() {
							document.getElementById("description").innerHTML = "Description: "
									+ resource.getColumnValue("description");
							document.getElementById("time").innerHTML = "Time: "
									+ resource.getColumnValue("time");
							document.getElementById("amount").innerHTML = "Amount: "
									+ resource.getColumnValue("amount");
							document.getElementById("addc").href = "addContractContributor.htm?id="
									+ id;
							document.getElementById("addp").href = "addPaying.htm?contractId="
									+ id;
							for ( var i = resource.getChildren().length - 1; i >= 0; i--) {
								var childres1 = resource.getChildren()[i];
								if (childres1.getURI().indexOf("collaborate") != -1) {
									document.getElementById("title").innerHTML = "Collaborate Contract No."
											+ id;
									document.getElementById("extend").innerHTML = "<p>Partner: "
											+ childres1
													.getColumnValue("partner")
											+ "</p>";
								} else if (childres1.getURI().indexOf("donate") != -1) {
									document.getElementById("title").innerHTML = "Donate Contract No."
											+ id;
									document.getElementById("extend").innerHTML = "<p>Limit: "
											+ childres1.getColumnValue("limit")
											+ "</p>";
								} else if (childres1.getURI().indexOf(
										"endowment") != -1) {
									document.getElementById("title").innerHTML = "Endowment Contract No."
											+ id;
									document.getElementById("extend").innerHTML = "<p>Capital: "
											+ childres1
													.getColumnValue("capital")
											+ "</p><p>Rate: "
											+ childres1.getColumnValue("rate")
											+ "</p>";
								} else if (childres1.getURI().indexOf("reward") != -1) {
									document.getElementById("title").innerHTML = "Reward Contract No."
											+ id;
									document.getElementById("extend").innerHTML = "<p>Reason: "
											+ childres1
													.getColumnValue("reason")
											+ "</p>";
								} else {
									var childres = childres1.getChildren()[0];
									if (childres.getURI().indexOf("paying") != -1) {
										var payingId = childres
												.getColumnValue("primarykey");
										var currency = childres.getChildren()[0]
												.getChildren()[0];
										var row = document.getElementById(
												"payings").insertRow(1);
										row.align = "center";
										row.innerHTML = "<td>"
												+ childres
														.getColumnValue("date")
												+ "</td><td>"
												+ currency
														.getColumnValue("primarykey")
												+ "</td><td>"
												+ currency
														.getColumnValue("rate")
												+ "</td><td>"
												+ childres
														.getColumnValue("amount")
												+ "</td><td><a href=\"addPaying.htm?id="
												+ payingId
												+ "\">edit</a> <a class=\"deletelink\" onclick=\"deletePaying("
												+ id
												+ ","
												+ payingId
												+ ",reloadCurrent)\">delete</a></td>";
									} else if (childres.getURI().indexOf(
											"contributor") != -1) {
										var contributorId = childres
												.getColumnValue("primarykey");
										var row = document.getElementById(
												"contributors").insertRow(1);
										row.align = "center";
										row.innerHTML = "<td><a href=\"contributor.htm?id="
												+ contributorId
												+ "\">"
												+ contributorId
												+ "</a></td><td><a href=\"contributor.htm?id="
												+ contributorId
												+ "\">"
												+ childres
														.getColumnValue("name")
												+ "</a></td><td>"
												+ childres
														.getColumnValue("size")
												+ "</td><td>"
												+ childres.getChildren()[0]
														.getChildren()[0]
														.getColumnValue("type")
												+ "</td><td><a href=\"addContributor.htm?id="
												+ contributorId
												+ "\">edit</a> <a class=\"deletelink\" onclick=\"deleteContributor("
												+ id
												+ ","
												+ contributorId
												+ ",reloadCurrent)\">delete</a></td>";
									}
								}
							}
						});
	</script>
</body>
</html>
